package cn.smile.controller.basic;

import cn.smile.bean.dto.basic.TopUpBillDTO;
import cn.smile.bean.form.basic.bill.QueryTopUpForm;
import cn.smile.bean.form.basic.bill.TopUpAddForm;
import cn.smile.business.basic.ITopUpBillService;
import cn.smile.commons.response.MyResult;
import com.baomidou.mybatisplus.core.metadata.IPage;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;

@RestController
@RequestMapping("api/topUpBill")
public class TopUpBillController {
    @Resource
    private ITopUpBillService service;

    @PostMapping(value = "addTopUp")
    public MyResult<Boolean> addTopUp(@Valid @RequestBody TopUpAddForm form) {
        return MyResult.OK(service.addTopUp(form));
    }

    @PostMapping(value = "getPage")
    public MyResult<IPage<TopUpBillDTO>> getPage(@RequestBody QueryTopUpForm form) {
        return MyResult.OK(service.getPage(form));
    }

    @GetMapping(value = "delTopUp")
    public MyResult<Boolean> delTopUp(@RequestParam("id") String id){
        return MyResult.OK(service.delTopUp(id));
    }

    @GetMapping(value = "getBillById")
    public MyResult<TopUpBillDTO> getBillById(@RequestParam("id") String id){
        return MyResult.OK(service.getBillById(id));
    }
}
